﻿//-----------------------------------------------------------------------
// <copyright file="DialogControlPage.cs" company="Noboru Project">
//      Copyright (c) Noboru Project. All rights reserved.
//
//      This source code is subject to terms and conditions of the New BSD License (BSD).
//      A copy of the license can be found in the License.html file at the root of this 
//      distribution. If you can not locate the New BSD License (BSD), please send an 
//      email to noboru_adm@live.com.
//      By using this source code in any fashion, you are agreeing to be bound by
//      the terms of the New BSD License (BSD) for Noboru.
//
//      You must not remove this notice, or any other, from this software.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Noboru.Windows.Controls;

namespace Noboru.Demo
{
    public partial class DialogControlPage : UserControl
    {
        public DialogControlPage()
        {
            InitializeComponent();
        }

        private void ShowDialogButton_Click(object sender, RoutedEventArgs e)
        {
            DialogControl dialogControl = new DialogControl();

            dialogControl.Title = this.txtTitle.Text;
            if (this.RadioModal.IsChecked.Value)
            {
                dialogControl.Modal = DialogModal.Modal;
            }
            else if (this.RadioModalGray.IsChecked.Value)
            {
                dialogControl.Modal = DialogModal.ModalGray;
            }

            double width;
            if (double.TryParse(this.txtWidth.Text, out width))
            {
                dialogControl.Width = width;
            }

            double height;
            if (double.TryParse(this.txtHeight.Text, out height))
            {
                dialogControl.Height = height;
            }

            if (this.ShowImage.IsChecked.Value)
            {
                dialogControl.DisplayImage = true;
            }

            if (this.SetImage.IsChecked.Value)
            {
                dialogControl.ImageSource = new BitmapImage(new Uri("images/Users.png", UriKind.Relative));
            }

            if (this.RadioTopLeft.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.TopLeft;
            }
            else if (this.RadioTopCenter.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.TopCenter;
            }
            else if (this.RadioTopRight.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.TopRight;
            }
            else if (this.RadioCenterLeft.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.CenterLeft;
            }
            else if (this.RadioCenter.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.Center;
            }
            else if (this.RadioCenterRight.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.CenterRight;
            }
            else if (this.RadioBottomLeft.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.BottomLeft;
            }
            else if (this.RadioBottomCenter.IsChecked.Value)
            {
                dialogControl.OpenPosition = DialogOpenPosition.BottomCenter;
            }
            else
            {
                dialogControl.OpenPosition = DialogOpenPosition.BottomRight;
            }

            dialogControl.Show();
        }
    }
}
